#!/bin/bash
##################################################################
## function: compress log 
## eg：./log_compress.sh
## author: shx
## createdate: 20150908 
## version:     
################################################################## 
. /home/hadoop/shx/baseUtil.sh


if [[ ! -n "$1" ]] && [[ ! -n "$2" ]] ;then
	HISTORYDATE=`date -d '-1 days'  +%Y%m%d`
else
	HISTORYDATE=$1
fi

root_path=/flume/original/track

root_path=$root_path"/"$HISTORYDATE

for((k=0;k<=23;k++));
do  
  fhour=$k
  if [[ $k -lt 10 ]]; then
    fhour='0'$k
  fi
 
  filepath=$root_path"/"$fhour"/*.lzo"
  echo "================"$filepath

  path_array=(`hadoop fs -ls $filepath  |awk -F " " '{print $8}'`)

  for sub_path in ${path_array[@]};do

    filename=${sub_path}
    echo $filename
    /usr/local/cloud/hadoop/bin/hadoop  jar /usr/local/cloud/hadoop/share/hadoop/common/hadoop-lzo-0.4.20-SNAPSHOT.jar com.hadoop.compression.lzo.LzoIndexer $filename
  done
done
